//
// Created by yasin on 2024/9/9.
//

#include "rtc_log.h"

Logger logger_;

Logger& GetLogger() {
  return logger_;
}


std::string GetTimestamp() {
  // 获取当前时间点
  auto now = std::chrono::system_clock::now();
  auto now_as_time_t = std::chrono::system_clock::to_time_t(now);
  auto now_ms = std::chrono::duration_cast<std::chrono::milliseconds>(now.time_since_epoch()) % 1000;

  // 转换为tm结构
  std::tm* now_tm = std::localtime(&now_as_time_t);

  // 将时间和毫秒格式化为字符串
  std::stringstream ss;
  ss << std::put_time(now_tm, "%Y-%m-%d %H:%M:%S");
  ss << '.' << std::setfill('0') << std::setw(3) << now_ms.count();
  return ss.str();
}